# -*- coding: utf-8 -*-
# Python 将列表中的头尾两个元素对调

# demo-1
def swapList(newList):
    size = len(newList)

    temp = newList[0]
    newList[0] = newList[size - 1]
    newList[size - 1] = temp

    return newList

newList = [1, 2, 3]
print(newList)

print(swapList(newList))
# [3, 2, 1]

# demo-2
def swapList(list):
    newList[0], newList[-1] = newList[-1], newList[0]

    return newList

newList = [1, 2, 3]
print(newList)
print(swapList(newList))

# demo-3
def swapList(list):
    get = list[-1], list[0]
    list[0], list[-1] = get

    return list

newList = [1, 2, 3]
print(newList)
print(swapList(newList))